package com.hope;

import android.content.Context;
import android.content.SharedPreferences;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Vibrator;
import android.preference.PreferenceManager;

public class Notify {
	private Context context;
	
	public Notify(Context c) {
		context = c;
	}
	
	public void notifyUser() {
		SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
		
		if (settings.getBoolean("pref_notification", true)) {
			vibrate(settings.getBoolean("pref_vibrate", true));
			
			String media = settings.getString("pref_sound", "DEFAULT_SOUND");
	        Uri uri = Uri.parse(media);
			Ringtone ring = RingtoneManager.getRingtone(context, uri);
			ring.play();
		}
	}
	
	public void vibrate(boolean b) {
		if (b) {
			Vibrator vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
	        vibrator.vibrate(1000);
		}
	}
}
